package com.demo.java.crawl.utils;

import us.codecraft.webmagic.Page;

public class PageUtils {

    public static String xpathText(Page page, String xpath) {
        String tmp = page.getHtml().xpath(xpath + "/text()").toString();
        if (tmp == null) {
            return null;
        }
        return tmp.trim();
    }

    public static String xpathEle(Page page, String xpath) {
        return page.getHtml().xpath(xpath).toString();
    }
}
